pkgname=mutilate
pkgver=0.1
pkgrel=1
pkgdesc="a memcached load generator designed for high request rates, good tail-latency measurements, and realistic request stream generation."
arch=(i386 x86_64)
url="https://github.com/leverich/mutilate"
license=(BSD 3-clause "New" or "Revised" License)
depends=(scons libevent-dev gengetopt libzmq-dev memcached)
makedepends_debian_11=(scons libevent-dev gengetopt libzmq3-dev)
source=('https://github.com/leverich/mutilate.git' 'http://ftp.gnu.org/gnu/gengetopt/gengetopt-2.23.tar.xz')
md5sums=('SKIP' 'SKIP')

build_gengetopt(){
        cd "$srcdir/gengetopt-2.23"
        ./configure
        make
        make install
}

patch_source() {
	cd "$srcdir/mutilate"

	# if scons isn't python3 version, no need apply patch
	scons -v | grep -q "python3" || return 0

	patch -p1 < "$LKP_SRC/pkg/${pkgname}/0001-SConstruct-update-to-python3-version.patch"
}

build()
{
	[ "$os" == "openeuler" ] && build_gengetopt
	cd "$srcdir/mutilate"
	scons
}

package()
{
	[ "$os" == "openeuler" ] && {
                cd "$srcdir/gengetopt-2.23"
                make DESTDIR="$pkgdir" install
        }
	install -D "$srcdir/$pkgname/mutilate" "$pkgdir/usr/local/bin/mutilate"
}
